package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.Classification;
import com.burgeon.backend.SHOPBACKEND.entity.Employee;
import com.burgeon.backend.SHOPBACKEND.entity.Seckill;
import com.burgeon.backend.SHOPBACKEND.service.BackendFindDataService;
import com.burgeon.backend.entity.CouponType;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RequestMapping("backend/find")
@CrossOrigin
@RestController
public class BackendFindDataController extends BaseController{
    @Autowired
    private BackendFindDataService backendFindDataService;

    /**
     * 秒杀搜索
     * @param field A 款号 B品
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findSeckillData")
    public ResponseResult<List<Seckill>> findSeckillData(String field, String message, String account) {

        List<Seckill> data = backendFindDataService.findSeckillData(field, message, account);

        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }



    /**
     *
     * @param field A单据编号 B原云仓订单 C退货状态 D顾客姓名 E顾客手机 F购买日期 G单据日期 H商品

     * @param start
     * @param account
     * @return
     */
    @RequestMapping("findRefundData")
    public ResponseResult<HashMap> findRefundData(String field, String message, Integer start, String account) {
        HashMap data = backendFindDataService.findRefundData(field, message, start, account);
        return new ResponseResult<HashMap>(SUCCESS, data);
    }

    /**
     * 查找商品缓存
     * @param field A 名称  B 款号
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findcache")
    public ResponseResult<List<Classification>> findCache(String field, String message, String account) {
        List<Classification> data = backendFindDataService.findGoodsCache(field, message, account);
        return new ResponseResult<List<Classification>>(SUCCESS,data);
    }

    /**
     *
     * @param start A 款号 B 名称
     * @param field
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findFABData")
    public ResponseResult<HashMap> findFABData(Integer start,String field,String message, String account) {
        HashMap data = backendFindDataService.findFABData(start,field,message,account );
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    /**
     * 时间段查找订单
     * @param start 页码 每页10条
     * @param state 订单状态
     * @param field A:下单时间 B支付时间 C:发货时间 D结束时间
     * @param startTime 开始时间 2020-12-18 01:45:20
     * @param endTime 结束时间 2020-12-18 01:45:20
     * @param account
     * @return
     */
    @RequestMapping("findorderbytime")
    public ResponseResult<HashMap> findOrderDataByTime(Integer start,String state,String field, String startTime,String endTime, String account) {
        HashMap data = backendFindDataService.findOrderDataByTime(account,state,field,startTime,endTime,start);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }


    /**
     *
     * @param account
     * @param state
     * @param field A会员电话 B订单编号 C会员姓名
     * @param message
     * @param start
     * @return
     */
    @RequestMapping("findorder")
    public ResponseResult<HashMap> findOrderData(Integer start,String state,String field, String message, String account) {
        HashMap data = backendFindDataService.findOrderData(account,state,field,message,start);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }
    /**
     * 查找vip
     * @param start
     * @param field A:姓名  B:电话
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findvip")
    public ResponseResult<HashMap> findvip(Integer start,String field, String message, String account) {
        HashMap data = backendFindDataService.findVipData(start, field, message, account);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    /**
     * 查找emp
     *
     * @param field A姓名 B电话 C销售区域
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findemp")
    public ResponseResult<List<Employee>> findemp(String field, String message, String account) {
        List<Employee> data = backendFindDataService.findEMPData(field,message,account);
        return new ResponseResult<List<Employee>>(SUCCESS,data);
    }

    /**
     * 查找门店
     * @param field A:NAME 店仓名称 B:C_CUSTOMER_ID;NAME所属经销商  CONTACTOR_ID;NAME联系人
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findstore")
    public ResponseResult<HashMap> findstore(String field, String message, String account) {
        HashMap data = backendFindDataService.FindStoreData(field, message, account);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    /**
     * 查找商品
     * @param start
     * @param field A:款号  B:标签 C:品名 D:原价 E:是否上架 F:活动名称 G:大分类id
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findgoods")
    public ResponseResult<HashMap> findgoods(Integer start,String field, String message, String account) {
        HashMap data = backendFindDataService.FindGoodsData(start,field, message, account);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    /**
     * 购物券类型
     * @param start
     * @param field A名称 B优惠金额 C结束时间 D应用场景 1线上2线下3通用
     * @param message
     * @param account
     * @return
     */
    @RequestMapping("findcoupontype")
    public ResponseResult<List<CouponType>> findcoupontype(String field, String message, String account) {
        List<CouponType> data = backendFindDataService.getCouponType(field, message, account);
        return new ResponseResult<List<CouponType>>(SUCCESS,data);
    }


    /**
     * 获取销售区域
     * @param account
     * @return
     */
    @RequestMapping("getarea")
    public ResponseResult<List<String>> getarea(String account) {
        List<String> data = backendFindDataService.getAREA(account);
        return new ResponseResult<List<String>>(SUCCESS,data);
    }



}
